const rm = require('rimraf')
const path = require('path')
const __root__ = process.cwd()
const dev = require('./conf/webpack.dev.conf')
const pro = require('./conf/webpack.prod.conf')
const config = require('./conf/config')

module.exports = {

	webpackConf: {
		dev,
		pro,
	},

	devFunc(grunt) {
		grunt.registerTask('dev', 'dev env', function() {
			rm(path.join(config.build.assetsRoot, config.dev.assetsSubDirectory), (err) => {
				console.log(err, 11111111111)
			})
			grunt.task.run(['webpack:dev', 'concurrent:dev'])
		});
	},

	proFunc(grunt) {
		grunt.registerTask('pro', 'production env', function() {
			rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), (err) => {
				console.log(err, 11111111111)
			})
			rm(path.join(config.build.assetsRoot, config.dev.assetsSubDirectory), (err) => {
				console.log(err, 11111111111)
			})
			grunt.task.run(['webpack:pro'])
		});
	},
}